CSharpTest.Net
Merge(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>[]) Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedKeyValuePairs<TKey,TValue> Class > Merge Method : Merge(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>[]) Method

comparer
enums

Glossary Item Box

Merges n-number of ordered enumerations based on the comparer provided.

Syntax

Visual Basic (Declaration) 
Public Overloads Shared Function Merge( _
   ByVal comparer As IComparer(Of TKey), _
   ByVal ParamArray enums() As IEnumerable(Of KeyValuePair(Of TKey,TValue)) _
) As IEnumerable(Of KeyValuePair(Of TKey,TValue))

Parameters

comparer
enums

Example

Library/Library.Test/TestOrderedEnumeration.cs

C#Copy Code
var x = new[] { new KeyValuePair<int, int>(1, 1) };
var y = new[] { new KeyValuePair<int, int>(2, 2) };

IEnumerator<KeyValuePair<int, int>> e = 
    OrderedKeyValuePairs<int, int>
    .Merge(new ReverseOrder<int>(Comparer<int>.Default), x, y)
    .GetEnumerator();

Assert.IsTrue(e.MoveNext());
Assert.AreEqual(2, e.Current.Key);
Assert.IsTrue(e.MoveNext());
Assert.AreEqual(1, e.Current.Key);
Assert.IsFalse(e.MoveNext());
VB.NETCopy Code
Dim x As var = New () {New KeyValuePair(Of Integer, Integer)(1, 1)}
Dim y As var = New () {New KeyValuePair(Of Integer, Integer)(2, 2)}

Dim e As IEnumerator(Of KeyValuePair(Of Integer, Integer)) = OrderedKeyValuePairs(Of Integer, Integer).Merge(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), x, y).GetEnumerator()

Assert.IsTrue(e.MoveNext())
Assert.AreEqual(2, e.Current.Key)
Assert.IsTrue(e.MoveNext())
Assert.AreEqual(1, e.Current.Key)
Assert.IsFalse(e.MoveNext())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys